{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "babfa0fd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "当前时间为2025-09-12 11:33:45\n",
      "\n",
      "您的出生时间为1992-01-07 17:00:00\n",
      "\n",
      "出生到现在的经历日子12301天,你已经33.7岁了\n",
      "\n"
     ]
    }
   ],
   "source": [
    "import time  # 引入time模块\n",
    "\n",
    "ticks = time.time()\n",
    "print('当前时间为{}\\n'.format(time.strftime(\"%Y-%m-%d %H:%M:%S\",time.localtime())))\n",
    "\n",
    "input_date='1992-01-07 17:00:00'\n",
    "#  时间元祖\n",
    "struct_time = time.strptime(input_date, '%Y-%m-%d %H:%M:%S')\n",
    "print('您的出生时间为{}\\n'.format(time.strftime(\"%Y-%m-%d %H:%M:%S\",struct_time)))\n",
    "\n",
    "# 时间戳\n",
    "input_timestamp = time.mktime(struct_time)\n",
    "\n",
    "print('出生到现在的经历日子{}天,你已经{}岁了\\n'.format(int((time.time()-input_timestamp)/86400),\n",
    "                                  round((time.time()-input_timestamp)/86400/365,2)\n",
    "                                  ))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "fa186d9a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "活到2030-01-01需要经过的经历日子13873天，约还有7年\n",
      "\n"
     ]
    }
   ],
   "source": [
    "future_date='2030-01-01'\n",
    "future_timestamp = time.mktime(time.strptime(future_date, '%Y-%m-%d'))\n",
    "\n",
    "print('活到{}需要经过的经历日子{}天，约还有{}年\\n'.format(future_date, int((future_timestamp-input_timestamp)/86400),\n",
    "                                   int((future_timestamp-time.time())/86400/365)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "440d9299",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.3820890410958904"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "11157/(80*365)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cba28112",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.2"
  },
  "vscode": {
   "interpreter": {
    "hash": "40d3a090f54c6569ab1632332b64b2c03c39dcf918b08424e98f38b5ae0af88f"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
